package com.dd.cloud.user.mapper.consult;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dd.cloud.user.entity.consult.ConsultSubscribe;
import com.dd.cloud.user.req.consult.ConsultDoctorPageReq;
import com.dd.cloud.user.req.consult.ConsultSubscribeDoctorPageReq;
import com.dd.cloud.user.req.consult.ConsultSubscribePageReq;
import com.dd.cloud.user.res.chat.ConsultDoctorPageRes;
import com.dd.cloud.user.res.chat.InquiryDateQueueRes;
import com.dd.cloud.user.res.consult.*;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 预约问诊表 Mapper 接口
 * </p>
 *
 * @author czg
 * @since 2023-07-07
 */
public interface ConsultSubscribeMapper extends BaseMapper<ConsultSubscribe> {

    /**
     * 查询医生问诊排班
     */
    List<InquiryDateQueueRes> inquiryScheduling(@Param("date") LocalDate date);

    /**
     * 查询医生咨询排班
     */
    List<InquiryDateQueueRes> consultScheduling(@Param("date") LocalDate date);

    /**
     * 分页查询问诊的医生列表
     */
    Page<ConsultDoctorPageRes> consultDoctorList(@Param("page") Page<ConsultDoctorPageRes> page, @Param("req") ConsultDoctorPageReq req);

    /**
     * 患者查询预约记录
     */
    Page<ConsultSubscribePageRes> consultPage(@Param("page") Page<ConsultSubscribePageRes> page, @Param("req") ConsultSubscribePageReq req);

    /**
     * 患者查询预约详情
     */
    ConsultSubscribeDetailRes consultDetail(@Param("id") Integer id);

    /**
     * @param iPage
     * @param req
     * @return
     */
    IPage<ConsultSubscribeDoctorPageRes> queryConsultSubscribeDoctorPage(IPage<?> iPage, @Param("req") ConsultSubscribeDoctorPageReq req);

    /**
     * 查询医生待办消息
     *
     * @param doctorId
     * @return
     */
    ConsultMsgUnReadCountRes queryConsultMsgUnReadCountDoctor(@Param("doctorId") Integer doctorId);

    /**
     * 查询医生在线问诊在线咨询待接诊数量
     *
     * @param doctorId
     * @return
     */
    ConsultUnReceiveCountRes queryConsultUnReceiveCountDoctor(@Param("doctorId") Integer doctorId);

    /**
     * 获取消息记录
     *
     * @param id
     * @param page
     * @return
     */
    IPage<UserInfoRes> queryImTencent(@Param("page") IPage<UserInfoRes> page,
                                      @Param("consultId") Integer consultId);

    /**
     * 用户未读数
     */
    ConsultMsgUnReadCountRes queryConsultMsgUnReadCountUser(@Param("userId") Integer userId);
}
